package com.yang.web;

import java.io.IOException;
import java.sql.SQLException;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import net.sf.json.JSONArray;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import com.yang.service.PositionService;
import com.yang.util.TransformUtil;

@Controller
@RequestMapping("/position")
public class PositionController {

	@Resource(name="PositionServiceImpl")
	private PositionService service;
	
	@RequestMapping("/getPositionList")
	public void getPositionList(HttpServletRequest request, HttpServletResponse response,
			@RequestParam("companyId") String companyId){
		List<Map<String, String>> list = null;
		JSONArray jsonArray = null;
		
		try {
			list = service.selectPositionList(companyId);
			jsonArray = TransformUtil.list2JsonArray(list);
			response.setCharacterEncoding("utf-8");
			response.getWriter().write(jsonArray.toString());
		} catch (SQLException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
	
	
}
